#ifndef PATIENTMODEL_H
#define PATIENTMODEL_H

#include "LoadPatientList_global.h"
#include "../../DataManager/UserRepository/UserRepository.h"
#include <QAbstractListModel>
#include <QString>
#include <QList>
#include <QVariant>
#include <QVector>


namespace UserManagementSystem {

class LOADPATIENTLIST_EXPORT PatientModel:public QAbstractListModel
{
    Q_OBJECT
public:
    PatientModel(UserManagementSystem::UserRepository* repository,QObject* parent=nullptr);

    ///@brief 一个data接口返回index指向的数据
    QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;

    ///@brief 返回model的总行数，告知viewList要显示多少行的数据
    int rowCount(const QModelIndex &parent = QModelIndex()) const override;

    ///@brief 将index处的数据设置为value
    bool setData(const QModelIndex &index, const QVariant &value, int role) override;

private:
    ///@brief 从repository中加载患者数据
    void LoadPatients();

private:
    ///@brief 一个从数据库读取数据的类
    UserManagementSystem::UserRepository* m_userDataRepository=nullptr;

    ///@brief 获得的患者数据存储在这个成员变量中
    QList<PatientData> m_patients;



};

}

#endif // PATIENTMODEL_H
